/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_PIPE_H
#define MK_PIPE_H
#include "MkUtil/MkTypes.h"

class CMkEvent;
class MkApi CMkPipe
{
public:
    CMkPipe(CMkEvent* pEvent);
    virtual ~CMkPipe();

    Uint32 Start(const MkFunction<void()>& Cb);
    Uint32 Active();
protected:
    Uint32 OnRecv();
private:
    CMkEvent*           m_pEvent;
    SOCKET              m_PipFd[2];  //send is index 1 recv is index 0
    MkFunction<void()>  m_Cb;
};

#endif
